package com.xiaoshuidi.cloud.module.member.enums.topics;

import cn.hutool.core.lang.Assert;
import com.xiaoshuidi.cloud.module.member.enums.StatusEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * @description: 话题状态
 * @author: Jax.Lan
 * @create: 2023-05-31 16:19
 **/
@Getter
@AllArgsConstructor
public enum TopicsStateEnum {
//1.未生效2进行中3已结束
    TO_BE_EFFECTIVE(1,"未生效"), // 待生效
    EFFECTIVE(2,"进行中"), // 生效中
    EXPIRE(3,"已结束"); // 失效


    private Integer code;
    private String name;

    public static String getNameByCode(Integer code) {
        TopicsStateEnum topicsStateEnum = Arrays.stream(TopicsStateEnum.values()).filter(p -> p.code.intValue() == code.intValue()).findFirst().orElse(null);
        Assert.isTrue(topicsStateEnum != null, "TopicsStateEnum:{}不存在", code);
        return topicsStateEnum.getName();
    }
}
